@echo off
echo ===================================================
echo        FinData and PandaFactor Shutdown
echo ===================================================

:: Stop Nginx
echo [1/3] Stopping Nginx...
set NGINX_PATH=C:\nginx
if exist "%NGINX_PATH%\nginx.exe" (
    "%NGINX_PATH%\nginx.exe" -s stop 2>nul
    echo Nginx stopped
) else (
    echo Nginx is not installed or path is incorrect
)

:: Stop PandaFactor
echo [2/3] Stopping PandaFactor...
call stop_panda_factor.bat

:: Stop FinData
echo [3/3] Stopping FinData...
taskkill /f /fi "WINDOWTITLE eq FinData System*" 2>nul
taskkill /f /im dotnet.exe 2>nul

:: Kill all potentially remaining processes
echo Cleaning up all remaining processes...
taskkill /f /fi "WINDOWTITLE eq MongoDB*" 2>nul
taskkill /f /im mongod.exe 2>nul

echo.
echo ===================================================
echo        All services stopped
echo ===================================================
echo.

pause 